﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="user_list.aspx.cs" Inherits="background.Manager.Users.user_list" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../Styles/index.css" rel="stylesheet" />
    <script src="../Scripts/jquery-1.8.2.min.js"></script>
    <script src="../Scripts/layer/layer.js"></script>

    <script type="text/javascript">
        function resetPassword(obj) {
            if (confirm("确定要重置密码吗？")) {
                $(obj).attr("disabled", "disabled");
                $.post("../Action/fromData.ashx", { action: "updatePwd", id: $(obj).attr("data-id"), password: "admin888" }, function (ret) {
                    if (ret) {
                        layer.msg("恭喜您密码重置成功", { icon: 1 });
                        $(obj).css("background","#ccc");
                    } else {
                        layer.msg("对不起密码重置失败", { icon: 2 });
                        $(obj).removeAttr("disabled");
                    }
                })
            }
        }
        function massDelete() {
            var d = new Array();
            $("input[name='idbox']:checked").each(function () { d.push($(this).val()); })
            if (d.length == 0) { layer.msg("请选择要删除的项"); return; }
            
            if (confirm("确定要删除所选项吗？")) {
                $.post("../Action/fromData.ashx", { action: "delete", idList: d.join(',') }, function (ret) {
                    if (ret) {
                        layer.msg("删除成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起删除失败，稍后再试", { icon: 2 });
                    }
                })
            }
        }
        function deletes(id) {
            if (confirm("确定要删除吗？")) {
                $.post("../Action/fromData.ashx", { action: "delete", idList:id }, function (ret) {
                    if (ret) {
                        layer.msg("删除成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起删除失败，稍后再试", { icon: 2 });
                    }
                })
            }
        }
        function checkboxAll(obj) {
            $("input[name='idbox']").attr("checked", $(obj).is(":checked"));
        }
    </script>
    <script type="text/javascript">if ('<%=(Session[ManagerConfig.bg("sessionName")]==null).ToString().ToLower()%>'== 'true') { window.parent.location = '../login.aspx'; }</script>
</head>
<body>
    <div class="top">
        <strong>管理员管理</strong>
        <span style="float: right"><a href="javascript:history.back();">
            <img src="../Images/bak.png" />后退</a></span>
    </div>
    <div class="main">
        <div>
            <div class="tool_search">
               <input type="button" class="sbtn" value="添加管理员" onclick="window.location.href='create_user.aspx'" />&nbsp;&nbsp;<input type="button" class="sbtn" value="批量删除" onclick="    massDelete()" />&nbsp;&nbsp;<input type="button" class="sbtn" value="修改当前管理员密码" onclick="window.location.href = 'update_password.aspx'" /><a></a>
            </div>
            <table border="0" cellpadding="0" cellspacing="0" class="listtable">
                <tr>
                    <th class="th" style="width: 20px">
                        <input type="checkbox" onchange="checkboxAll(this)" /></th>
                    <th class="th">用户昵称</th>
                    <th class="th">登录帐号</th>
                    <th class="th">密码</th>
                    <th class="th">创建日期</th>
                    <th class="th thlast">操作</th>
                </tr>
                <%System.Data.DataTable dt= ManagerConfig.getUsers(); %>
                <% int j=1; foreach(System.Data.DataRow dr in dt.Rows) {%>
                <tr <%=j%2==0?"class='tr2'":"" %>>
                    <td class="td">
                        <input type="checkbox" name="idbox" value="<%=dr["id"] %>" /></td>
                    <td class="td"><%=dr["nickname"] %></td>
                    <td class="td"><%=dr["loginname"] %></td>
                    <td class="td">
                        <input type="button" class="mbtn" value="重置为：admin888" data-id="<%=dr["ID"] %>" onclick="resetPassword(this)" /></td>
                    <td class="td"><%=((DateTime)dr["addtime"]).ToString("yyyy/MM/dd HH:mm") %></td>
                    <td class="td tdlast txtcenter">
                        <a href="edit_user.aspx?id=<%=dr["id"] %>">
                            <img src="../Images/edit.png" class="tool_edit" />编辑</a>
                        <a href="javascript:void(0);" onclick="deletes(<%=dr["id"] %>)">
                            <img src="../Images/delete.png" class="tool_delete" />删除</a></td>
                </tr>
                <%j++;
                   } %>
            </table>
        </div>
    </div>
    <!--#include file='../Include/footer.html'-->
</body>
</html>
